﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.Data.DbUtils.DataMapping;
using PMS.Data.Entities.SystemModules;

namespace PMS.Data.EntityMap.SystemModules
{
    /// <summary>
    /// Represents a SystemModule-CustomerRole mapping configuration
    /// </summary>
    public partial class SystemModuleCustomerRoleMappingMap : PMSEntityTypeConfiguration<SystemModuleCustomerRoleMapping>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<SystemModuleCustomerRoleMapping> builder)
        {
            builder.ToTable("systemmodule_customerrole_mapping");
            builder.HasKey(mapping => new { mapping.SystemModuleId, mapping.CustomerRoleId });
            builder.Property(mapping => mapping.SystemModuleId).HasColumnName("SystemModule_Id");
            builder.Property(mapping => mapping.CustomerRoleId).HasColumnName("CustomerRole_Id");
            builder.Property(mapping => mapping.ViewPermission).IsRequired();
            builder.Property(mapping => mapping.AuthorizedButtonIds).HasMaxLength(1024);
            builder.Ignore(mapping => mapping.Id);
            builder.Ignore(mapping => mapping.IsActive);
            builder.Ignore(mapping => mapping.AuthorizedButtons);
            builder.Ignore(mapping => mapping.CreatedOnTimeUtc);
            builder.Ignore(mapping => mapping.UpdatedOnTimeUtc);
            base.Configure(builder);
        }

        #endregion
    }
}
